﻿namespace TestProject
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using logika;
    using System.Collections.Generic;

    [TestClass]
    public class WriteTree
    {
        Node _root;
        WriterReader pen;
        List<string> leaves;

        [TestInitialize]
        public void setup()
        {
            pen = new WriterReader();
            _root = TreeSimulator.getBirdTree();
            pen.children = new List<string>();
            pen.children.Add(_root.sekwencja);
            pen.tree = "(1:" + _root.wiek.ToString() + ",";
            leaves = TreeSimulator.getListOfBirdsLeaves();
            pen.properTree = leaves;
            pen.CountNodes(_root, 0);
            pen.tree += ");";
        }

        [TestMethod]
        public void CountNodesGetsProperListOfLeaf()
        {
            Assert.AreEqual(leaves.Count, pen.children.Count);
        }
        
        [TestMethod]
        public void CountNodesGetsProperStringTree()
        {
            string getsTree = pen.tree;
            string properTree = TreeSimulator.getProperTextTree();
            Assert.AreEqual(properTree, getsTree);
            pen.Save(_root, "drzewko.tre");
        }

        [TestMethod]
        public void DontMessSimpleTree()
        {
            pen = new WriterReader();
            _root = TreeSimulator.getBirdTree();
            pen.Save(_root);
            pen.WriteToFile();
        }
    }
}
